#ifndef CAN_TEST_H
#define CAN_TEST_H

#define WRITE_COM     0x02
#define READ_COM      0x03
#define RESET_COM     0x0C
#define STATUS_COM    0xA0
#define STATUS_RX_COM 0xB0

#define SPI_READ_RX   0x90
#define	SPI_WRITE_TX  0x40
#define	SPI_RTS	      0x80

#define CANINTE       0x2B
#define CANINTF       0x2C

#define LOOPBACK_MODE 0x40
#define NORMAL_MODE   0x00
#define CONFIG_MODE   0x80

typedef struct {
  int id;
  int length;
  int rtr;
  char buff[22];
} 
tCAN;

// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 49;
int startupMode = LOOPBACK_MODE;

void spiReset();
void spiWrite(int address, int value);
char spiWriteContInit(int address);
char spiWriteCont(int data);
int spiRead(int address, int verbose=0);
char spiReadContInit(int address);
char spiReadCont();
char getStatus();
int hasMessage(void);
int recMessage(tCAN *msg);
int sendMessage(tCAN *msg);

#endif
